package xhe.openapi.service.impl;

import org.springframework.stereotype.Service;

import xhe.entities.ApiEntity;
import xhe.enums.VersionEnum;
import xhe.openapi.service.OpenAPIService;

@Service
public class OpenAPIServiceImpl implements OpenAPIService {

	@Override
	public ApiEntity get(ApiEntity apiEntity, VersionEnum apiVersion) {

		xhe.lib.data.Get apiServices = new xhe.lib.data.Get();

		if (apiVersion == VersionEnum.V2_0) {

			return apiServices.Get_2_0(apiEntity);

		} else if (apiVersion == VersionEnum.V3_0) {

			return apiServices.Get_3_0(apiEntity);

		} else {
			return apiServices.Get_1_0(apiEntity);
		}
	}

	@Override
	public ApiEntity edit(ApiEntity apiEntity) {

		xhe.lib.data.Edit apiServices = new xhe.lib.data.Edit();

		return apiServices.Edit_1_0(apiEntity);
	}

	@Override
	public ApiEntity add(ApiEntity apiEntity) {

		xhe.lib.data.Add apiServices = new xhe.lib.data.Add();

		return apiServices.Add_1_0(apiEntity);
	}

	@Override
	public ApiEntity getEx(ApiEntity apiEntity, VersionEnum apiVersion) {

		xhe.lib.data.Get apiServices = new xhe.lib.data.Get();

		if (apiVersion == VersionEnum.V1_1) {

			return apiServices.GetEx_1_1(apiEntity);

		} else if (apiVersion == VersionEnum.V1_2) {

			return apiServices.GetEx_1_2(apiEntity);

		} else {
			return apiServices.GetEx_1_0(apiEntity);
		}
	}

	@Override
	public ApiEntity getQuota(ApiEntity apiEntity, VersionEnum apiVersion) {

		xhe.lib.data.Get apiServices = new xhe.lib.data.Get();

		if (apiVersion == VersionEnum.V2_0) {

			// return apiServices.Get_2_0(apiEntity);

			return null;

		} else if (apiVersion == VersionEnum.V3_0) {

			// return apiServices.Get_3_0(apiEntity);

			return null;

		} else {
			return apiServices.GetQuota_1_0(apiEntity);
		}
	}
}
